import BaseSingleClass from "@/BaseSingleClass";
import cjs = createjs;
import axios from "axios";
import MessageController from "../MessageController";
import { ControlEvent } from "@/const";
import BaseController from "../BaseController";
/**
 * 加载控制器
 */
export default class LoadController extends BaseController {
    private loader=new cjs.LoadQueue(false)
    getResult(value:string):any{
        return this.loader.getResult(value);
    }
    start(){
        // 加载资源
        axios.get("/assets/game/json/game1.json").then(res=>{
            console.log(res.data)
            const resource=res.data.preload;
            this.loader.loadManifest(resource);
            this.loader.on("complete",()=>{
                console.log("加载完成")
                this.message.send(ControlEvent.START_GAME);
            })
            this.loader.on('progress',(e:cjs.ProgressEvent):void=>{
                console.log(e.progress)
                //console.log(e instanceof cjs.ProgressEvent)
            })
        })
    }
}